﻿<%@ Page Title="Notas e Faltas" Language="C#" MasterPageFile="~/Site.Master"
    AutoEventWireup="true" CodeBehind="NotasFaltas.aspx.cs" Inherits="AcadPosApp.Lancamentos.NotasFaltas" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script type="text/javascript">
        function setaFoco(elemento) {
            var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;

            if (keyCode == 13) {
                var i;
                for (i = 0; i < elemento.form.elements.length; i++)
                    if (elemento == elemento.form.elements[i])
                        break;
                i = (i + 1) % elemento.form.elements.length;
                elemento.form.elements[i].focus();
                event.preventDefault();
                return false;
            }
            return false;
        }

        function formatar_mascara(src, mascara) {
            var campo = src.value.length;
            var saida = mascara.substring(0, 1);
            var texto = mascara.substring(campo);
            if (texto.substring(0, 1) != saida) {
                src.value += texto.substring(0, 1);
            }
        }


        function saltar() {
            if (event.keyCode == 13) {
                event.keyCode = 9;
            }
        } 
    </script>
    <style type="text/css">
        .style2
        {
            width: 318px;
        }
        .style3
        {
            width: 312px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:Panel ID="pnlPesquisa" runat="server" GroupingText="Consulta de Cursos">
                <table class="form-inline">
                    <tr>
                        <td class="style2">
                            Áreas de Conhecimento
                        </td>
                        <td>
                            &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td class="style2">
                            <asp:DropDownList ID="ddlAreaConhecimento" runat="server" Width="300px" AutoPostBack="True"
                                OnSelectedIndexChanged="ddlAreaConhecimento_SelectedIndexChanged">
                            </asp:DropDownList>
                        </td>
                        <td>
                            &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td class="style2">
                            Descrição
                        </td>
                        <td>
                            &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td class="style2">
                            <asp:TextBox ID="txtPesquisa" runat="server" MaxLength="250" Width="300px" required=""></asp:TextBox>
                            <!-- <asp:RequiredFieldValidator ID="requiredPesquisa" runat="server" ControlToValidate="txtPesquisa"
                                ErrorMessage="É necessário preencher o campo pesquisa!" ForeColor="Red" ValidationGroup="pesquisa"
                                SetFocusOnError="True">*</asp:RequiredFieldValidator> -->
                        </td>
                        <td>
                            <asp:Button ID="btnConsultar" runat="server" OnClick="btnConsultar_Click"
                                Text="Consultar" ValidationGroup="pesquisa" />
                        </td>
                    </tr>
                </table>
                <br />
                <asp:GridView ID="gvwPesquisa" runat="server" AutoGenerateColumns="False" CssClass="mGrid"
                    DataKeyNames="ID_CURSO" EmptyDataText="Dados não localizados..." GridLines="Vertical"
                    Width="60%" OnRowDataBound="gvwPesquisa_RowDataBound" AllowPaging="True" OnPageIndexChanging="gvwPesquisa_PageIndexChanging"
                    OnSelectedIndexChanged="gvwPesquisa_SelectedIndexChanged">
                    <AlternatingRowStyle BackColor="#D3D3D3" />
                    <Columns>
                        <asp:CommandField ButtonType="Image" SelectImageUrl="~/Imagens/select.png" ShowSelectButton="True">
                            <ItemStyle Width="1%" />
                        </asp:CommandField>
                        <asp:BoundField DataField="ID_CURSO" HeaderText="Código">
                            <HeaderStyle HorizontalAlign="Center" Width="1%" />
                            <ItemStyle HorizontalAlign="Center" Width="1%" />
                        </asp:BoundField>
                        <asp:BoundField DataField="DESCRICAO" HeaderText="Cursos">
                            <ItemStyle HorizontalAlign="Left" Width="75%" />
                        </asp:BoundField>
                        <asp:TemplateField HeaderText="Status">
                            <ItemTemplate>
                                <asp:Image ID="imgStatus" runat="server" Height="25px" Width="25px" />
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Width="1%" />
                            <ItemStyle HorizontalAlign="Center" Width="1%" />
                        </asp:TemplateField>
                        <asp:BoundField DataField="SITUACAO" HeaderText="Situação">
                            <ItemStyle Width="10%" HorizontalAlign="Center" />
                        </asp:BoundField>
                    </Columns>
                    <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
                    <PagerStyle CssClass="pagination" ForeColor="Black" HorizontalAlign="Center" />
                    <SelectedRowStyle BackColor="#1E90FF" Font-Bold="True" ForeColor="White" />
                    <SortedAscendingCellStyle BackColor="#F1F1F1" />
                    <SortedAscendingHeaderStyle BackColor="#808080" />
                    <SortedDescendingCellStyle BackColor="#CAC9C9" />
                    <SortedDescendingHeaderStyle BackColor="#383838" />
                </asp:GridView>
                <br />
                <table class="form-inline">
                    <tr>
                        <td>
                            Currículo
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:DropDownList ID="ddlCurriculoPesquisa" runat="server" AutoPostBack="True" Enabled="false"
                                OnSelectedIndexChanged="ddlCurriculoPesquisa_SelectedIndexChanged" 
                                Width="150px">
                            </asp:DropDownList>
                        </td>
                    </tr>
                </table>
                <table class="form-inline">
                    <tr>
                        <td>
                            Módulo
                            <br />
                            <asp:DropDownList ID="ddlModuloPesquisa" runat="server" AutoPostBack="True" Enabled="False"
                                OnSelectedIndexChanged="ddlModuloPesquisa_SelectedIndexChanged" 
                                Width="300px">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Label ID="Label1" runat="server" Text="Disciplina"></asp:Label>
                            <br />
                            <asp:DropDownList ID="ddlDisciplinas" runat="server" AutoPostBack="True" Enabled="False"
                                OnSelectedIndexChanged="ddlDisciplina_SelectedIndexChanged" Width="300px">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Label ID="Label2" runat="server" Text="Estado"></asp:Label>
                            <br />
                            <asp:DropDownList ID="ddlEstado" runat="server" OnSelectedIndexChanged="ddlEstado_SelectedIndexChanged"
                                Width="150px" AutoPostBack="True" Enabled="False">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Polo
                            <br />
                            <asp:DropDownList ID="ddlPolo" runat="server" AutoPostBack="True" Enabled="False"
                                OnSelectedIndexChanged="ddlPolo_SelectedIndexChanged" Width="400px">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Label ID="Label3" runat="server" Text="Turma"></asp:Label>
                            <br />
                            <asp:DropDownList ID="ddlTurmas" runat="server" Enabled="False" Width="150px">
                            </asp:DropDownList>
                        </td>
                        <tr>
                            <td rowspan="1">
                                <asp:Label ID="Label4" runat="server" Text="Modo Lançamento" Visible="False"></asp:Label>
                                <asp:RadioButtonList ID="rbTipo" runat="server" RepeatDirection="Horizontal" AutoPostBack="True"
                                    OnSelectedIndexChanged="rbTipo_SelectedIndexChanged" Visible="False">
                                    <asp:ListItem Selected="True">Notas</asp:ListItem>
                                    <asp:ListItem>Frequência</asp:ListItem>
                                </asp:RadioButtonList>
                                <br />
                                <asp:Button ID="btnPesquisar" runat="server" Text="Consultar" 
                                    OnClick="btnPesquisar_Click" Width="100px"
                                     />
                                    <br />
                                <br />
                                <br />
                            </td>
                        </tr>
                </table>
            </asp:Panel>
            <br />
            <asp:Panel ID="pnlNotas" runat="server" GroupingText="Lançamento Notas" Visible="False">
                <asp:GridView ID="gvwLancNotas" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                    CssClass="mGrid" EmptyDataText="Dados não localizados..." GridLines="Vertical"
                    Width="60%" OnRowCancelingEdit="gvwLancNotas_RowCancelingEdit" OnRowEditing="gvwLancNotas_RowEditing"
                    OnRowUpdating="gvwLancNotas_RowUpdating" 
                    DataKeyNames="ID_MATRICULA_DISCIPLINA">
                    <AlternatingRowStyle BackColor="#D3D3D3" />
                    <Columns>
                        <asp:BoundField DataField="MATRICULA" HeaderText="Matrícula" ReadOnly="True">
                            <ItemStyle HorizontalAlign="Left" Width="5%" />
                        </asp:BoundField>
                        <asp:BoundField DataField="NOME" HeaderText="Nome" ReadOnly="True">
                            <ItemStyle HorizontalAlign="Left" Width="60%" />
                        </asp:BoundField>
                        <asp:TemplateField HeaderText="Nota1">
                            <EditItemTemplate>
                                <asp:TextBox ID="txtNota1" HorizontalAlign="Center" MaxLength="5" runat="server"
                                    onkeypress="setaFoco(this)" onFocus="this.select()" Text='<%# Bind("NOTA1") %>'
                                    Width="80px"></asp:TextBox>
                                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtNota1"
                                    ErrorMessage="Campo Nota aceita apenas números e vírgula." ValidationExpression="([\,0-9]+)"
                                    ValidationGroup="gravar">*</asp:RegularExpressionValidator>
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# Bind("NOTA1") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Width="80px" />
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Nota2">
                            <EditItemTemplate>
                                <asp:TextBox ID="txtNota2" HorizontalAlign="Center" MaxLength="5" runat="server"
                                    onkeypress="setaFoco(this)" onFocus="this.select()" Text='<%# Bind("NOTA2") %>'
                                    Width="80px"></asp:TextBox>
                                <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="txtNota2"
                                    ErrorMessage="Campo Nota aceita apenas números e vírgula." ValidationExpression="([\,0-9]+)"
                                    ValidationGroup="gravar" Font-Bold="False">*</asp:RegularExpressionValidator>
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# Bind("NOTA2") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Width="80px" />
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:TemplateField>
                        <asp:BoundField DataField="SITUACAO" HeaderText="Situação" ReadOnly="True">
                            <ItemStyle HorizontalAlign="Center" Width="5%" />
                        </asp:BoundField>
                        <asp:CommandField ButtonType="Button" CancelText="Cancelar" EditText="Alterar" ShowEditButton="True"
                            UpdateText="Salvar" ValidationGroup="gravar">
                            <ControlStyle CssClass="btn btn-success" />
                            <HeaderStyle Width="120px" />
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:CommandField>
                    </Columns>
                    <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
                    <PagerStyle CssClass="pagination" ForeColor="Black" HorizontalAlign="Center" />
                    <SelectedRowStyle BackColor="#1E90FF" Font-Bold="True" ForeColor="White" />
                    <SortedAscendingCellStyle BackColor="#F1F1F1" />
                    <SortedAscendingHeaderStyle BackColor="#808080" />
                    <SortedDescendingCellStyle BackColor="#CAC9C9" />
                    <SortedDescendingHeaderStyle BackColor="#383838" />
                </asp:GridView>
                <asp:ValidationSummary ID="ValidationSummary2" runat="server" ShowMessageBox="True"
                    ShowSummary="False" ValidationGroup="gravar" />
            </asp:Panel>
            <br />
            <asp:Panel ID="pnlFrequencia" runat="server" GroupingText="Lançamento Frequência"
                Visible="False">
                <asp:DropDownList ID="DropDownList1" runat="server" Width="150px">
                </asp:DropDownList>
                <br />
                <asp:GridView ID="gvwLancFrequencia" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                    CssClass="mGrid" DataKeyNames="ID_MATRICULA_DISCIPLINA" EmptyDataText="Dados não localizados..."
                    GridLines="Vertical" Width="45%">
                    <AlternatingRowStyle BackColor="#D3D3D3" />
                    <Columns>
                        <asp:BoundField DataField="MATRICULA" HeaderText="Matrícula" ReadOnly="True">
                            <ItemStyle HorizontalAlign="Left" Width="5%" />
                        </asp:BoundField>
                        <asp:BoundField DataField="NOME" HeaderText="Nome" ReadOnly="True">
                            <ItemStyle HorizontalAlign="Left" Width="75%" />
                        </asp:BoundField>
                        <asp:TemplateField HeaderText="Nota1">
                            <EditItemTemplate>
                                <asp:TextBox ID="txtNota3" runat="server" HorizontalAlign="Center" 
                                    MaxLength="5" onFocus="this.select()" onkeypress="setaFoco(this)" 
                                    Text='<%# Bind("NOTA1") %>' Width="80px"></asp:TextBox>
                                <asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" 
                                    ControlToValidate="txtNota1" 
                                    ErrorMessage="Campo Nota aceita apenas números e vírgula." 
                                    ValidationExpression="([\,0-9]+)" ValidationGroup="gravar">*</asp:RegularExpressionValidator>
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label5" runat="server" Text='<%# Bind("NOTA1") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Width="80px" />
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Nota2">
                            <EditItemTemplate>
                                <asp:TextBox ID="txtNota4" runat="server" HorizontalAlign="Center" 
                                    MaxLength="5" onFocus="this.select()" onkeypress="setaFoco(this)" 
                                    Text='<%# Bind("NOTA2") %>' Width="80px"></asp:TextBox>
                                <asp:RegularExpressionValidator ID="RegularExpressionValidator4" runat="server" 
                                    ControlToValidate="txtNota2" 
                                    ErrorMessage="Campo Nota aceita apenas números e vírgula." Font-Bold="False" 
                                    ValidationExpression="([\,0-9]+)" ValidationGroup="gravar">*</asp:RegularExpressionValidator>
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label6" runat="server" Text='<%# Bind("NOTA2") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Width="80px" />
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:TemplateField>
                        <asp:BoundField DataField="SITUACAO" HeaderText="Situação" ReadOnly="True">
                            <ItemStyle HorizontalAlign="Center" Width="10%" />
                        </asp:BoundField>
                        <asp:CommandField ButtonType="Button" CancelText="Cancelar" EditText="Alterar" 
                            ShowEditButton="True" UpdateText="Salvar" ValidationGroup="gravar">
                        <ControlStyle CssClass="btn btn-success" />
                        <HeaderStyle Width="120px" />
                        <ItemStyle HorizontalAlign="Center" />
                        </asp:CommandField>
                    </Columns>
                    <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
                    <PagerStyle CssClass="pagination" ForeColor="Black" HorizontalAlign="Center" />
                    <SelectedRowStyle BackColor="#1E90FF" Font-Bold="True" ForeColor="White" />
                    <SortedAscendingCellStyle BackColor="#F1F1F1" />
                    <SortedAscendingHeaderStyle BackColor="#808080" />
                    <SortedDescendingCellStyle BackColor="#CAC9C9" />
                    <SortedDescendingHeaderStyle BackColor="#383838" />
                </asp:GridView>
            </asp:Panel>
        </ContentTemplate>
       <%-- <Triggers>
            <asp:PostBackTrigger ControlID="gvwLancNotas" />
        </Triggers>--%>
    </asp:UpdatePanel>
</asp:Content>
